home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 147 / Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z / Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin / tools / ex68v209 / ex68v209.lzh / X6_UTIL.LZH / READFD.C < prev    next >
C/C++ Source or Header  |  1998-10-09  |  2KB  |  102 lines

  1.  
  2. #include <stdio.h>
  3. #include <iocslib.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <basic.h>
  7.  
  8. int drive_num=0;
  9. int start_trk=0;
  10. int end_trk=77;
  11. char file_name[256];
  12.  
  13. int chk_arg(int argc,char **argv)
  14. {
  15. int i,j;
  16. char abuff[256];
  17.     for(i=1; i<argc; i++)
  18.     {
  19.         strcpy(abuff,argv[i]);
  20.         for(j=1; j<strlen(abuff); j++)
  21.             abuff[j]=tolower(abuff[j]);
  22.         if (abuff[0]=='/')
  23.             abuff[0]='-';
  24.         if (!strncmp(abuff,"-h",2))
  25.         {
  26.             printf("readfd.x -d[0|1] -f[file] -s[0..76] -e[1..77]\n");
  27.             printf("   -d[0|1] ドライブ番号指定 デフォルト(0) \n");
  28.             printf("   -f[file] 出力ファイル名 (FD0.XDF)\n");
  29.             printf("   -s[0..76] 開始トラック (0) \n");
  30.             printf("   -e[1..77] 終了トラック (77) \n");
  31.             exit(1);
  32.         }
  33.         if (strlen(abuff)<3)
  34.         {
  35.             printf("option error (%s)\n",abuff);
  36.             return 1;
  37.         }
  38.         if (!strncmp(abuff,"-d",2))
  39.         {
  40.             drive_num=atoi(&abuff[2]);
  41.             if ((drive_num<0) || (drive_num>3))
  42.                 drive_num=0;
  43.         }
  44.         else if (!strncmp(abuff,"-f",2))
  45.         {
  46.             strcpy(file_name,&abuff[2]);
  47.         }
  48.         else if (!strncmp(abuff,"-s",2))
  49.         {
  50.             start_trk=atoi(&abuff[2]);
  51.             if ((start_trk<0) || (start_trk>80))
  52.                 start_trk=0;
  53.         }
  54.         else if (!strncmp(abuff,"-e",2))
  55.         {
  56.             end_trk=atoi(&abuff[2]);
  57.             if ((end_trk<0) || (end_trk>80))
  58.                 start_trk=77;
  59.         }
  60.         else
  61.         {
  62.             printf("option error (%s)\n",abuff);
  63.             return 1;
  64.         }
  65.     }
  66.     return 0;
  67. }
  68.  
  69. void main(int argc,char **argv)
  70. {
  71. int sect,side,track,res;
  72. char buff[1024*8];
  73. FILE *fp;
  74.     printf("readfd.x v1.1\n");
  75.     strcpy(file_name,"FD0.XDF");
  76.     if (chk_arg(argc,argv))
  77.         exit(1);
  78.         
  79.     fp=fopen(file_name,"wb");
  80.  
  81.     for(track=start_trk; track<end_trk; track++)
  82.     for(side=0; side<2; side++)
  83.     {
  84.         sect=1;
  85.         printf("track %2d side %d .. \r",track,side);
  86.         res=B_READ(0x9070+(drive_num<<8),
  87.             ((((((3<<8)+track)<<8)+side)<<8)+sect),1024*8,buff);
  88.         if ((res&0xffffff00)==0xffffff00)
  89.         {
  90.             printf("read error!\n");
  91.             exit(1);
  92.         }
  93.         fwrite(buff,1,1024*8,fp);
  94.     }
  95.     if (fclose(fp))
  96.     {
  97.         printf("\write error!\n");
  98.         exit(1);
  99.     }
  100.     printf("\n\n");
  101. }
  102.